/*
 * MsgWinHandler.h
 *
 *  Created on: 2012-12-18
 *      Author: yangentao@gmail.com
 */
#pragma once;
#include <Windows.h>
#include "Handler.h"
/*
 void onMsg(Message msg) {
 cout << "onMsg: " << msg.msg << endl;
 }
 static void test() {
 WinLoop loop;
 HWNDHandler h;
 h.OnMessage = onMsg;
 bool b = h.start();
 cout << b << endl;
 if (b) {
 h.post(Message(123));
 h.post(Message(456));
 }
 loop.loop();
 }
 *
 */

namespace yet {

//message handler in main thread
//use "Message" window for msg notify,  win msg loop require!
class HWNDHandler: public Handler {
public:
	HWNDHandler();
	virtual ~HWNDHandler();
protected:
	void notify();
	bool onStart();
	void onQuit();
private:
	WNDPROC preProc;
	HWND w;
	friend LRESULT CALLBACK MsgWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
};

} /* namespace yet */
